//
//  SZYHMyEmailViewController.m
//  苏州银行
//
//  Created by rimi on 15/8/20.
//  Copyright (c) 2015年 IOS. All rights reserved.
//

#import "SZYHMyEmailViewController.h"
#import "Config.h"

@interface SZYHMyEmailViewController ()

@property (nonatomic, strong)UIView *muenView;
@property (nonatomic, strong)UIView *emailView;
@property (nonatomic, assign)CGFloat width;
@property (nonatomic, assign)CGFloat height;

@end

@implementation SZYHMyEmailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor clearColor];
    _width = self.view.frame.size.width;
    _height = self.view.frame.size.height;
    

    [self initializeUserInterface];
    
    
}

- (void)initializeUserInterface{
    
    _muenView = [[UIView alloc]initWithFrame:self.view.bounds];
    _muenView.backgroundColor = [UIColor blackColor];
    _muenView.alpha = 0;
    [self.view addSubview:_muenView];

    
    UIButton *globalButton = [[UIButton alloc]initWithFrame:self.view.bounds];
    [globalButton addTarget:self action:@selector(outViewButtonEvent:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:globalButton];
    
    
    _emailView = [[UIView alloc]initWithFrame:CGRectMake(200, 150, _width - 400, _height - 300)];
    UIImageView *emailImageView = [[UIImageView alloc]initWithFrame:_emailView.bounds];
    [emailImageView setImage:IMGNAME(@"消息推送_信箱背景")];
    [_emailView addSubview:emailImageView];
    [self.view addSubview:_emailView];
    _emailView.transform = CGAffineTransformMakeRotation(-30);
    _emailView.layer.position = CGPointMake(_width / 2, -400);
    
    
    [UIView animateWithDuration:0.5 animations:^{
        _muenView.alpha = 0.7;
        _emailView.layer.position = self.view.center;
        _emailView.transform = CGAffineTransformIdentity;
    }];
    
}


- (void)outViewButtonEvent:(UIButton *)sender{
    
    [UIView animateWithDuration:0.5 animations:^{
        _muenView.alpha = 0;
        _emailView.transform = CGAffineTransformMakeRotation(30);
        _emailView.layer.position = CGPointMake(_width / 2, _height + 400);
    } completion:^(BOOL finished) {
        [self.view removeFromSuperview];
        self.view = nil;
    }];
    
}
@end
